<template>
  <div class="header">
    <div class="title">社区智慧治理数据平台</div>
    <div class="clock">
      {{ currentTime }}
    </div>
    <div class="border-effect"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentTime: '',
    };
  },
  mounted() {
    this.updateTime();
    setInterval(this.updateTime, 1000);
  },
  methods: {
    updateTime() {
      const now = new Date();
      const year = now.getFullYear();
      const month = String(now.getMonth() + 1).padStart(2, '0');
      const day = String(now.getDate()).padStart(2, '0');
      const weekday = ['日', '一', '二', '三', '四', '五', '六'][now.getDay()];
      const hours = String(now.getHours()).padStart(2, '0');
      const minutes = String(now.getMinutes()).padStart(2, '0');
      const seconds = String(now.getSeconds()).padStart(2, '0');
      this.currentTime = `${year}-${month}-${day} 星期${weekday} ${hours}:${minutes}:${seconds}`;
    },
  },
};
</script>

<style scoped>
.header {
  text-align: center;
  position: relative;
  padding: 20px;
  background: linear-gradient(to right, #00bcd4, #009688);
  color: white;
}
.title {
  font-size: 24px;
  font-weight: bold;
}
.clock {
  margin-top: 10px;
  font-size: 18px;
}
.border-effect {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid transparent;
  animation: border-glow 3s infinite;
}
@keyframes border-glow {
  0% { border-color: transparent; }
  50% { border-color: #ffeb3b; }
  100% { border-color: transparent; }
}
</style>
